<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<header th:replace="admin/header::header-fragment"></header>
<body class="hold-transition sidebar-mini">
<link th:href="@{/admin/plugins/editormd/css/editormd.css}" rel="stylesheet"/>
<link th:href="@{/admin/plugins/tagsinput/jquery.tagsinput.css}" rel="stylesheet"/>
<link th:href="@{/admin/plugins/select2/select2.css}" rel="stylesheet"/>
<div class="wrapper">

  <div th:replace="admin/header::header-nav"></div>

  <div th:replace="admin/sidebar::sidebar-fragment(${path})"></div>

  <div class="content-wrapper">

    <div class="content-header">
      <div class="container-fluid">
      </div>
    </div>

    <div class="content">
      <div class="container-fluid">
        <div class="card card-primary card-outline">
          <div class="card-header">
            <h3 class="card-title">发布文章</h3>
          </div>
          <div class="card-body">

            <form id="blogForm" onsubmit="return false;">
              <div class="form-group" style="display:flex;">
                <input type="hidden" id="blogId" name="blogId" th:value="${blog!=null and blog.blogId!=null }?${blog.blogId}: 0">
                <input type="text" class="form-control col-sm-6" id="blogName" name="blogName"
                       placeholder="*请输入文章标题(必填)"
                       th:value="${blog!=null and blog.blogTitle!=null }?${blog.blogTitle}: ''"
                       required="true">
                &nbsp;&nbsp;
                <input type="text" class="form-control" id="blogTags" name="blogTags"
                       placeholder="请输入文章标签"
                       th:value="${blog!=null and blog.blogTags!=null }?${blog.blogTags}: ''"
                       style="width: 100%;">
              </div>
              <div class="form-group" style="display:flex;">
                <input type="text" class="form-control col-sm-6" id="blogSubUrl"
                       name="blogSubUrl"
                       th:value="${blog!=null and blog.blogSubUrl!=null }?${blog.blogSubUrl}: ''"
                       placeholder="请输入自定义路径,如:springboot-mybatis,默认为id"> &nbsp;&nbsp;
                <select class="form-control select2" style="width: 100%;" id="blogCategoryId"
                        data-placeholder="请选择分类...">
                  <th:block th:if="${null == categories}">
                    <option value="0" selected="selected">默认分类</option>
                  </th:block>
                  <th:block th:unless="${null == categories}">
                    <th:block th:each="c : ${categories}">
                      <option th:value="${c.categoryId}" th:text="${c.categoryName}"
                              th:selected="${null !=blog and null !=blog.blogCategoryId and blog.blogCategoryId==c.categoryId} ?true:false">
                        >
                      </option>
                    </th:block>
                  </th:block>
                </select>
              </div>
              <div class="form-group" id="blog-editormd">
                                <textarea style="display:none;"
                                          th:utext="${blog!=null and blog.blogContent !=null}?${blog.blogContent}: ''"></textarea>
              </div>
              <div class="form-group">

                &nbsp;<button class="btn btn-info float-right" style="margin-left: 5px;"
                              id="confirmButton">保存文章
              </button>&nbsp;
                &nbsp;<button class="btn btn-secondary float-right" style="margin-left: 5px;"
                              id="cancelButton">返回文章列表
              </button>&nbsp;
              </div>
            </form>
          </div>

        </div>
      </div>
    </div>
    <div class="content">
      <div class="modal fade" id="articleModal" tabindex="-1" role="dialog" aria-labelledby="articleModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                      aria-hidden="true">&times;</span></button>
              <h6 class="modal-title" id="articleModalLabel">信息完善</h6>
            </div>
            <div class="modal-body">
              <form onsubmit="return false;">
                <div class="form-group">
                  <div class="col-sm-4">
                    <th:block th:if="${null == blog}">
                      <img id="blogCoverImage" src="/admin/dist/img/img-upload.png"
                           style="height: 64px;width: 64px;">
                    </th:block>
                    <th:block th:unless="${null == blog}">
                      <img id="blogCoverImage" th:src="${blog.blogCoverImage}"
                           style="width:160px ;height: 120px;display:block;">
                    </th:block>
                  </div>
                </div>
                <br>
                <div class="form-group">
                  <div class="col-sm-4">
                    <button class="btn btn-info" style="margin-bottom: 5px;" id="uploadCoverImage">
                      <i class="fa fa-picture-o"></i>&nbsp;上传封面
                    </button>
                    <button class="btn btn-secondary" style="margin-bottom: 5px;"
                            id="randomCoverImage"><i
                            class="fa fa-random"></i>&nbsp;随机封面
                    </button>
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label">文章状态:&nbsp;</label>
                  <input name="blogStatus" type="radio" id="publish"
                         checked=true
                         th:checked="${null==blog||(null !=blog and null !=blog.blogStatus and blog.blogStatus==1)} ?true:false"
                         value="1"/>&nbsp;发布&nbsp;
                  <input name="blogStatus" type="radio" id="draft" value="0"
                         th:checked="${null !=blog and null !=blog.blogStatus and blog.blogStatus==0} ?true:false"/>&nbsp;草稿&nbsp;
                </div>
                <div class="form-group">
                  <label class="control-label">是否允许评论:&nbsp;</label>
                  <input name="enableComment" type="radio" id="enableCommentTrue" checked=true
                         th:checked="${null==blog||(null !=blog and null !=blog.enableComment and blog.enableComment==0)} ?true:false"
                         value="0"/>&nbsp;是&nbsp;
                  <input name="enableComment" type="radio" id="enableCommentFalse" value="1"
                         th:checked="${null !=blog and null !=blog.enableComment and blog.enableComment==1} ?true:false"/>&nbsp;否&nbsp;
                </div>
              </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
              <button type="button" class="btn btn-primary" id="saveButton">确认</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/admin/plugins/jQueryUI/jquery-ui.min.js}"></script>
<script th:src="@{/admin/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/admin/dist/js/adminlte.min.js}"></script>
<script th:src="@{/admin/plugins/editormd/editormd.min.js}"></script>
<script th:src="@{/admin/plugins/tagsinput/jquery.tagsinput.min.js}"></script>
<script th:src="@{/admin/plugins/select2/select2.full.min.js}"></script>
<script th:src="@{/admin/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/admin/plugins/ajaxupload/ajaxupload.js}"></script>
<script th:src="@{/admin/dist/js/public.js}"></script>
<script th:src="@{/admin/dist/js/edit.js}"></script>
</body>
</html>
